home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 019a / amac40.zip / SR.BAT < prev    next >
DOS Batch File  |  1991-05-14  |  4KB  |  94 lines

  1. :SR.BAT search/replace using FGREP.COM                         May 9, 1991
  2. :
  3. :1) SYNTAX:                           SR.BAT %1 %2 %3
  4. :                                  ┌──────────┘  │  └───────────┐
  5. :             (Mode)              %1            %2             %3
  6. :                            Search Text     Replace Text   File Name/List
  7. :         ----------------   -------------   ------------   --------------
  8. :      a) Query                   [ ]           [ ]            [ ]
  9. :      b) Partial Query      Search Text        [ ]            [ ]
  10. :      c) Partial Query      Search Text        [ ]         File Name/List
  11. :      d) Command line       Search Text     Replace Text      [ ]
  12. :      e) All command line   Search Text     Replace Text   File Name/List
  13. :
  14. :         where:    %1  - Search Text
  15. :                   %2  - Replace Text
  16. :                   %3  - File Name or [@File_List], default SRCH-FG.LST
  17. :                   [ ] - entered at query prompt
  18. :2) Requires FGREP.COM and INPUT.COM
  19. :3) Uses File_List %FileList% if no File Name is specified during input.
  20. :   Specify File Name list as [@FileList] to use an alternate File_List,
  21. :   or specify File Name, wild cards OK.
  22. :4) FGREP options──CANNOT──be changed from default "fl"
  23. :5) Set environment variable OPT=off to bypass File Name query prompt
  24. :   and use %FileList%. Set  OPT=    to *not* bypass File Name query prompt.
  25. :
  26. :
  27. :
  28. :*******************************************************************************
  29. :*                                                                             *
  30. :* Environment Variable        Action                                          *
  31. :* --------------------------- ----------------------------------------------- *
  32. :* set opt=                    does not bypass File Name query prompt          *
  33. :* set opt=off                 bypasses File Name query prompt                 *
  34. :* set filelist=               uses sm.lst for testing this batch file         *
  35. :* set filelist=srch-fg.lst    searches with standard file list srch-fg.lst    *
  36. :* set filelist=c:\srch-fg.lst searches with standard file list c:\srch-fg.lst *
  37. :* set srmac=                  macro files are located in current directory    *
  38. :* set srmac=c:\               macro files are located in c:\ directory        *
  39. :*                                                                             *
  40. :*******************************************************************************
  41. :
  42. @echo off
  43. cls
  44. set S~~=%1
  45. set R~~=%2
  46. set file=%3
  47. if     "%filelist%" == "" set filelist=sm.lst
  48. if not "%1" == ""    if not "%2" == "" goto 2b
  49. if not "%1" == ""    goto 1a
  50. if     "%1" == ""    echo Search Text: [{Blank} terminates batch file]
  51. INPUT.COM Search Text=/b
  52. if errorlevel=1 goto 6a
  53. set S~~=%ans%
  54. goto 2a
  55. :1a
  56. echo Search Text=%S~~%
  57. :2a
  58. set ans=
  59. if "%2" == "" echo Replace Text: [{Blank} terminates batch file]
  60. INPUT.COM Replace Text=/b
  61. if errorlevel=1 goto 6a
  62. set R~~=%ans%
  63. :2b
  64. set ans=
  65. if not "%opt%" == "" goto 2c
  66. if not    "%3" == "" goto 2c
  67. echo File Name(s): [{Blank}=%FileList%]  [File Name(s)]  [@FileList]
  68. INPUT.COM file list=/b
  69. set file=%ans%
  70. :2c
  71. if "%file%" == "@" set file=@%filelist%
  72. if "%file%" == ""  set file=@%filelist%
  73. :4a
  74. cls
  75. echo Search Text   = %S~~%
  76. echo Replace Text  = %R~~%
  77. echo File Name     = %file%
  78. break on
  79. FGREP.COM -fl /%S~~%/  %file% >c:\$.ql
  80. break off
  81. set >c:\$
  82. copy c:\$.ql c:\!
  83. Q.EXE        c:\!    /E%srmac%SRCH29.MAC /L%srmac%SRCH29.MAC
  84. goto 7a
  85. :6a
  86. echo.
  87. echo Search ──INCOMPLETE──
  88. goto 8a
  89. :7a
  90. echo.
  91. echo Search/Replace──Complete──
  92. :8a
  93. echo.
  94.